<?php

class Involved_NewsModel extends BaseModel
{

    protected $table = 'news';

    /**
     *资讯列表
     * @return mixed
     * $type 咨询类型 $t新闻条数
     */
    public function NewsIndexSelect($type,$t=null)
    {
        if($t){
            return DB::table($this->table)
                ->select('news_id','title','content','type','created','status','author','img','source')
                ->where('type',$type)
                ->orderBy('created', 'desc')
                ->skip(0)->take($t)
                ->get();
        }else{
            return DB::table($this->table)
                ->select('news_id','title','content','type','created','status','author','img','source')
                ->where('type',$type)
                ->orderBy('created', 'desc')
                ->get();
        }

    }

    /**
     * 公告查询
     * $type
     */
    public function AnnouncementListSelect($type,$t=null){
        if($t){
            return DB::table($this->table)
                ->select('news_id','title','type','created')
                ->where('type',$type)
                ->orderBy('created', 'desc')
                ->skip(0)->take($t)
                ->get();
        }else{
            return DB::table($this->table)
                ->select('news_id','title','type','created')
                ->where('type',$type)
                ->orderBy('created', 'desc')
                ->get();
        }
    }


    public function GetNewsId($news_id)
    {
        return DB::table($this->table)
            ->select('news_id','title','content','type','created','status','author','img','source')
            ->where('news_id',$news_id)
            ->first();
    }
}
